home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************/
- /* calllog.c */
- /* handles call log of Citadel-86 */
- /************************************************************************/
-
- #include "ctdl.h"
-
- /************************************************************************/
- /* history */
- /* */
- /* 86Mar07 HAW New users and .ts signals. */
- /* 86Feb09 HAW System up and down times. */
- /* 86Jan22 HAW Set extern var so entire system knows baud. */
- /* 85Dec08 HAW Put blank lines in file. */
- /* 85Nov?? HAW Created. */
- /************************************************************************/
-
- /************************************************************************/
- /* Contents */
- /* */
- /* logMessage() Put out str to file. */
- /************************************************************************/
-
- extern struct config cfg;
- extern int byteRate;
- static FILE *cl;
- FILE *safeopen();
-
- /************************************************************************/
- /* logMessage() Puts message out. Also, on date change, and */
- /* first output of system, insert blank line */
- /************************************************************************/
- logMessage(val, str, sig)
- char *str;
- char sig;
- char val;
- {
- struct timeData {
- int y, d, h, m;
- char *month;
- label person;
- char newuser;
- char evil;
- };
-
- static int oldDay = 0;
- static char *curBaud;
- static struct timeData lgin;
-
- int yr, dy, hr, mn;
- char *mon;
- label fn;
- char *format = "%s %d%s%02d @ %d:%02d\n";
-
- if (val == BAUD) {
- if (strCmp(str, "300" ) == SAMESTRING) byteRate = 30 ;
- else if (strCmp(str, "1200") == SAMESTRING) byteRate = 120;
- else if (strCmp(str, "2400") == SAMESTRING) byteRate = 240;
- else byteRate = 0 ;
- }
-
- if (cfg.call_log >= 100) return;
-
- getDate(&yr, &mon, &dy, &hr, &mn);
- switch (val) {
- case FIRST_IN:
- oldDay = dy;
- sPrintf(fn, "%c:calllog.sys", cfg.call_log + 'a');
- if ((cl = safeopen(fn, "a+")) == NULL)
- crashout("Call log error!");
- fprintf(cl, format, "System brought up",
- yr, mon, dy, hr, mn);
- break;
- case LAST_OUT:
- fprintf(cl, format, "System brought down",
- yr, mon, dy, hr, mn);
- fclose(cl);
- return;
- case BAUD: curBaud = str;
- lgin.person[0] = 0;
- return;
- case L_IN: lgin.y = yr;
- lgin.d = dy;
- lgin.h = hr;
- lgin.m = mn;
- lgin.newuser = sig;
- strCpy(lgin.person, str);
- lgin.month = mon;
- lgin.evil = FALSE;
- break;
- case EVIL_SIGNAL:
- lgin.evil = TRUE;
- break;
- case CARRLOSS:
- case L_OUT:
- if (!lgin.person[0]) {
- curBaud = NULL;
- break;
- }
-
- if (oldDay != dy)
- fprintf(cl, "\n");
-
- fprintf(cl, "%-22s: %2d%s%02d %2d:%02d - %2d:%02d (%s) %c %c %c\n",
- lgin.person, lgin.y, lgin.month, lgin.d, lgin.h, lgin.m,
- hr, mn, (curBaud == NULL) ? "sysConsole" : curBaud,
- (lgin.newuser) ? lgin.newuser : ' ', sig,
- lgin.evil ? 'E' : ' ');
- lgin.person[0] = 0;
-
- oldDay = dy;
- if (val == CARRLOSS) curBaud = NULL;
- break;
-
- default: printf("crashout: unknown case in switch statement");
- }
- fflush(cl);
- }
-